package com.base.taskreports.task.service.impl;

import com.base.taskreports.common.annotation.TBatchLog;
import com.base.taskreports.reports.entiyt.master.TIndicatorsEntity;
import com.base.taskreports.reports.entiyt.pqd.TblDiscountTransEnyity;
import com.base.taskreports.reports.service.TblDiscountTransService;
import com.base.taskreports.reports.service.impl.TIndicatorsServiceImpl;
import com.base.taskreports.task.service.LjService;
import com.base.taskreports.task.service.PqdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

//import net.sf.json.JSONObject;
@Service("PqdService")
public class PqdServiceImpl implements PqdService {

	@Autowired
	private TIndicatorsServiceImpl tIndicatorsServiceImpl ;

	@Autowired
	private TblDiscountTransService tblDiscountTransService ;

	@TBatchLog("PQD_M001")
	public void getPQD_M001(String strDate) {
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M001(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M001",strDate,list) ;
	}

	@TBatchLog("PQD_M002")
	public void getPQD_M002(String strDate) {
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M002(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M002",strDate,list) ;
	}

	@TBatchLog("PQD_M003")
	public void getPQD_M003(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M003(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M003",strDate,list) ;
	}

	@TBatchLog("PQD_M004")
	public void getPQD_M004(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M004(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M004",strDate,list) ;
	}

	@TBatchLog("PQD_M005")
	public void getPQD_M005(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M005(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M005",strDate,list) ;
	}

	@TBatchLog("PQD_M006")
	public void getPQD_M006(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M006(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M006",strDate,list) ;
	}

	@TBatchLog("PQD_M007")
	public void getPQD_M007(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M007(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M007",strDate,list) ;
	}

	@TBatchLog("PQD_M008")
	public void getPQD_M008(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M008(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M008",strDate,list) ;
	}

	@TBatchLog("PQD_M009")
	public void getPQD_M009(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M009(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M009",strDate,list) ;
	}

	@TBatchLog("PQD_M010")
	public void getPQD_M010(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M010(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M010",strDate,list) ;
	}

	@TBatchLog("PQD_M011")
	public void getPQD_M011(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M011(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M011",strDate,list) ;
	}

	@TBatchLog("PQD_M012")
	public void getPQD_M012(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M012(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M012",strDate,list) ;
	}

	@TBatchLog("PQD_M013")
	public void getPQD_M013(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M013(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M013",strDate,list) ;
	}

	@TBatchLog("PQD_M014")
	public void getPQD_M014(String strDate){
		List<TIndicatorsEntity> list = tblDiscountTransService.getPQD_M014(strDate) ;
		tIndicatorsServiceImpl.saveIndicators("PQD_M014",strDate,list) ;
	}

	public List<Object> getObjectList(TblDiscountTransEnyity tblDiscountTransEnyity ){

		List<Object> objectList = new ArrayList<Object>() ;

		objectList.add(tblDiscountTransEnyity.getTransId()) ;       // TRANS_ID
		objectList.add(tblDiscountTransEnyity.getOrigTransId()) ;   // ORIG_TRANS_ID
		objectList.add(tblDiscountTransEnyity.getTransDt()) ;       // TRANS_DT
		objectList.add(tblDiscountTransEnyity.getTransTs()) ;       // TRANS_TS
		objectList.add(tblDiscountTransEnyity.getTransTp()) ;       // TRANS_TP
		objectList.add(tblDiscountTransEnyity.getTransSt()) ;       // TRANS_ST
		objectList.add(tblDiscountTransEnyity.getTransChnl()) ;     // TRANS_CHNL
		objectList.add(tblDiscountTransEnyity.getTransSrc()) ;      // TRANS_SRC
		objectList.add(tblDiscountTransEnyity.getQid()) ;           // QID
		objectList.add(tblDiscountTransEnyity.getOrigQid()) ;       // ORIG_QID
		objectList.add(tblDiscountTransEnyity.getDiscountAt()) ;    // DISCOUNT_AT
		objectList.add(tblDiscountTransEnyity.getRefundAt()) ;      // REFUND_AT
		objectList.add(tblDiscountTransEnyity.getDiscountMchntAt()) ;   // DISCOUNT_MCHNT_AT
		objectList.add(tblDiscountTransEnyity.getRefundMchntAt()) ;   // REFUND_MCHNT_AT
		objectList.add(tblDiscountTransEnyity.getDiscountId()) ;   // DISCOUNT_ID
		objectList.add(tblDiscountTransEnyity.getDiscountTp()) ;   // DISCOUNT_TP
		objectList.add(tblDiscountTransEnyity.getDiscountCurr()) ;   // DISCOUNT_CURR
		objectList.add(tblDiscountTransEnyity.getDiscountCd()) ;   // DISCOUNT_CD
		objectList.add(tblDiscountTransEnyity.getMchntCd()) ;   // MCHNT_CD
		objectList.add(tblDiscountTransEnyity.getMchntTp()) ;   // MCHNT_TP
		objectList.add(tblDiscountTransEnyity.getMchntNm()) ;   // MCHNT_NM
		objectList.add(tblDiscountTransEnyity.getChnlMchntCd()) ;   // CHNL_MCHNT_CD
		objectList.add(tblDiscountTransEnyity.getMchntCtyCd()) ;   // MCHNT_CTY_CD
		objectList.add(tblDiscountTransEnyity.getOrderId()) ;   // ORDER_ID
		objectList.add(tblDiscountTransEnyity.getOrderAt()) ;   // ORDER_AT
		objectList.add(tblDiscountTransEnyity.getOrderCurr()) ;   // ORDER_CURR
		objectList.add(tblDiscountTransEnyity.getOrderTs()) ;   // ORDER_TS
		objectList.add(tblDiscountTransEnyity.getOrderDt()) ;   // ORDER_DT
		objectList.add(tblDiscountTransEnyity.getOrigOrderDt()) ;   // ORIG_ORDER_DT
		objectList.add(tblDiscountTransEnyity.getMobile()) ;   // MOBILE
		objectList.add(tblDiscountTransEnyity.getCardNo()) ;   // CARD_NO
		objectList.add(tblDiscountTransEnyity.getUsrId()) ;   // USR_ID
		objectList.add(tblDiscountTransEnyity.getIcTmn()) ;   // IC_TMN
		objectList.add(tblDiscountTransEnyity.getPosTmn()) ;   // POS_TMN
		objectList.add(tblDiscountTransEnyity.getCertId()) ;   // CERT_ID
		objectList.add(tblDiscountTransEnyity.getTokenCardNo()) ;   // TOKEN_CARD_NO
		objectList.add(tblDiscountTransEnyity.getPayMethod()) ;   // PAY_METHOD
		objectList.add(tblDiscountTransEnyity.getPayProductTp()) ;   // PAY_PRODUCT_TP
		objectList.add(tblDiscountTransEnyity.getAppId()) ;   // APP_ID
		objectList.add(tblDiscountTransEnyity.getLogId()) ;   // LOG_ID
		objectList.add(tblDiscountTransEnyity.getAccessId()) ;   // ACCESS_ID
		objectList.add(tblDiscountTransEnyity.getSysId()) ;   // SYS_ID
		objectList.add(tblDiscountTransEnyity.getFiled7()) ;   // FILED_7
		objectList.add(tblDiscountTransEnyity.getFiled11()) ;   // FILED_11
		objectList.add(tblDiscountTransEnyity.getFiled32()) ;   // FILED_32
		objectList.add(tblDiscountTransEnyity.getFiled33()) ;   // FILED_33
		objectList.add(tblDiscountTransEnyity.getMultiTp()) ;   // MULTI_TP
		objectList.add(tblDiscountTransEnyity.getMultiValue()) ;   // MULTI_VALUE
		objectList.add(tblDiscountTransEnyity.getResultCd()) ;   // RESULT_CD
		objectList.add(tblDiscountTransEnyity.getResultMsg()) ;   // RESULT_MSG
		objectList.add(tblDiscountTransEnyity.getRecCrtTs()) ;   // REC_CRT_TS
		objectList.add(tblDiscountTransEnyity.getRecUpdTs()) ;   // REC_UPD_TS
		objectList.add(tblDiscountTransEnyity.getExtraInfo()) ;   // EXTRA_INFO
		objectList.add(tblDiscountTransEnyity.getIsGray()) ;   // IS_GRAY
		objectList.add(tblDiscountTransEnyity.getDiscountInsAt()) ;   // DISCOUNT_INS_AT
		objectList.add(tblDiscountTransEnyity.getRefundInsAt()) ;   // REFUND_INS_AT

		return objectList ;
	}

	public List<List<Object>> getExcelList(List<TblDiscountTransEnyity> list){

		List<List<Object>> excelList = null ;

		if(list != null){

			excelList = new ArrayList<List<Object>>() ;

			for(TblDiscountTransEnyity tblDiscountTransEnyity : list){

				excelList.add(getObjectList(tblDiscountTransEnyity)) ;

			}
		}

		return excelList ;
	}

	public List<List<Object>> getPQD_M001_Detail(String previousDay) {
		List<TblDiscountTransEnyity> list = tblDiscountTransService.getPQD_M001_Detail(previousDay) ;
		return getExcelList(list) ;
	}

	public List<List<Object>> getPQD_M006_Detail(String previousDay) {
		List<TblDiscountTransEnyity> list = tblDiscountTransService.getPQD_M006_Detail(previousDay) ;
		return getExcelList(list) ;
	}

	public List<List<Object>> getPQD_M007_Detail(String previousDay) {
		List<TblDiscountTransEnyity> list = tblDiscountTransService.getPQD_M007_Detail(previousDay) ;
		return getExcelList(list) ;
	}

	public List<List<Object>> getPQD_M008_Detail(String previousDay) {
		List<TblDiscountTransEnyity> list = tblDiscountTransService.getPQD_M008_Detail(previousDay) ;
		return getExcelList(list) ;
	}

	public List<List<Object>> getPQD_M009_Detail(String previousDay) {
		List<TblDiscountTransEnyity> list = tblDiscountTransService.getPQD_M009_Detail(previousDay) ;
		return getExcelList(list) ;
	}

	public List<List<Object>> getPQD_M010_Detail(String previousDay) {
		List<TblDiscountTransEnyity> list = tblDiscountTransService.getPQD_M010_Detail(previousDay) ;
		return getExcelList(list) ;
	}

	public List<List<Object>> getPQD_M011_Detail(String previousDay) {
		List<TblDiscountTransEnyity> list = tblDiscountTransService.getPQD_M011_Detail(previousDay) ;
		return getExcelList(list) ;
	}

	public List<List<Object>> getPQD_M012_Detail(String previousDay) {
		List<TblDiscountTransEnyity> list = tblDiscountTransService.getPQD_M012_Detail(previousDay) ;
		return getExcelList(list) ;
	}

}
